package com.smartsofa.util;

import com.smartsofa.entity.InterestTag;

//calculate the score of user health

public class ScoreStipulate {
	float SBP; //收缩压
	float DBP; //舒张压
	float BG;//血糖
	float BOS;//血氧饱和度
	int score;
	String commentS = "";
	Boolean flagBoolean = true;
	public ScoreStipulate() {
		this.score = 100;
	}
	public ScoreStipulate(float SBP,float DBP,float BG,float BOS) {
		this.BG = BG;
		this.BOS = BOS;
		this.DBP = DBP;
		this.SBP = SBP;
		score = getScoreOfBG()+getScoreOfBOS()+getScoreOfDBP()+getScoreOfSBP();
		
	}
	private int getScoreOfSBP() {
		int scoreSBP = 25;
		if(SBP<90){
			scoreSBP = 0;
			commentS += "收缩压骗低；";
			flagBoolean = false;
		}else if (SBP>140) {
			scoreSBP = 0;
			commentS += "收缩压偏高; ";
			flagBoolean = false;
		}else{
			//如果血压正常，就从用户感兴趣Tag中去除血压
			InterestTag.interest_list.remove(InterestTag.XUEYA);
			scoreSBP = 25;
			flagBoolean = flagBoolean && true;
		}
		return scoreSBP;
	}
	private int getScoreOfDBP() {
		int scoreDBP = 25;
		if(DBP<60){
			scoreDBP = 0;
			commentS += "舒张压偏低; ";	
			flagBoolean = false;
		}else if (DBP>90) {
			scoreDBP = 0;
			commentS += "舒张压偏高; ";
			flagBoolean = false;
		}else{
			//如果血糖正常，就从用户感兴趣Tag中去除
			InterestTag.interest_list.remove(InterestTag.XUETANG);
			scoreDBP = 25;
			flagBoolean = flagBoolean && true;
		}
		return scoreDBP;
	}
	private int getScoreOfBG() {
		int scoreBG = 25;
		if(BG<3.9){
			scoreBG = 0;
			commentS += "血糖偏低; ";	
			flagBoolean = false;
		}else if (BG>11.1) {
			scoreBG = 0;
			commentS += "血糖偏高; ";
			flagBoolean = false;
		}else{
			//如果血氧饱和度正常，就从用户感兴趣Tag中去除
			InterestTag.interest_list.remove(InterestTag.XUEYANG);
			scoreBG = 25;
			flagBoolean = flagBoolean && true;
		}
		return scoreBG;
	}
	private int getScoreOfBOS() {
		int scoreBOS = 25;
		if(BOS<95){
			scoreBOS = 0;
			commentS += "血氧饱和度偏低; ";	
			flagBoolean = false;
		}else if (BOS>98) {
			scoreBOS = 0;
			commentS += "血氧饱和度偏高; ";
			flagBoolean = false;
		}else{
			scoreBOS = 25;
			flagBoolean = flagBoolean && true;
		}
		return scoreBOS;
	}
	public int getScore(){
		return score;
	}
	public String getComments(){
		if(flagBoolean == true){
			commentS = "您的身体非常健康!!!";
		}else{
			commentS += "您的健康可能出问题啦，请注意身体哦！ ";
		}
		return commentS;
	}

}
